package com.sqllog.listener;

import com.sqllog.entity.RowChangeInfo;
import lombok.extern.slf4j.Slf4j;

/**
 * 开始处理监听事件, 每个客户端只允许又一个监听器， 如果有多个，易导致 监听器之间相互影响
 *
 * @author chennengcheng
 * @date 2020-08-24 17:36
 * @remark
 */

@Slf4j
public abstract class SimpleCanalEventListener implements CanalEventListener {

    /**
     * 处理sql 消息日志
     * @param rowChangeInfo
     */
    public abstract void processSqlMessage(RowChangeInfo rowChangeInfo);

    @Override
    public void onEvent(RowChangeInfo rowChangeInfo) {
        try {
            processSqlMessage(rowChangeInfo);
        }catch (Exception e){
            callBackForException(rowChangeInfo, e);
        }
    }

}
